﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SWENAssignment.HuiYi
{
    public partial class deleteUserAccDisplay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            lblLoginID.Text = (string)Session["loginID"];
            if (!Page.IsPostBack)
            {
                userAccount u = DBmanager.GetUserAccountByLoginID(lblLoginID.Text);
                //lblLoginID.Text = Request.QueryString["loginID"];
                lblLoginID.Text = u.LoginID;
                lblUserType.Text = u.UserType;
                lblPassword.Text = u.Password;
                lblConfirmedPassword.Text = u.ConfirmedPassword;
                lblLastName.Text = u.LastName;
                lblFirstName.Text = u.FirstName;
                lblDob.Text = u.DateOfBirth.ToString("yyyy/MM/dd");
                lblContactNo.Text = u.ContNum.ToString();
                lblAddress.Text = u.MailAdd;
                lblEmail.Text = u.Email;
                lblGender.Text = u.Gender;
                lblBankAccType.Text = u.BankAccType;
                lblBankAccNo.Text = u.BankAccNum.ToString();
                
            }
        }

        protected void btnDelete_Click(object sender, EventArgs e)
        {
                userAccount deleteUserAccount = new userAccount();
                deleteUserAccount.LoginID = (string)Session["loginID"];

                if(DBmanager.DeleteUserAccount(deleteUserAccount) == 1)
            {
                
                lblDeletedSuccessfully.Text = "deletion successful!";
            }
            else
            {
                lblDeletedSuccessfully.Text = "deletion unsuccessful!";
            }
        }
    }
}